package com.eshop.modules.monitor.rest;

import com.eshop.annotation.Limit;
import io.swagger.annotations.ApiOperation;
import com.eshop.annotation.AnonymousAccess;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.concurrent.atomic.AtomicInteger;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({ "/api/limit" })
@Api(tags = { "系统：限流测试管理" })
public class LimitController
{
    private static final AtomicInteger ATOMIC_INTEGER;
    
    @GetMapping
    @AnonymousAccess
    @ApiOperation("测试")
    @Limit(key = "test", period = 60, count = 10, name = "testLimit", prefix = "limit")
    public int testLimit() {
        return LimitController.ATOMIC_INTEGER.incrementAndGet();
    }
    
    static {
        ATOMIC_INTEGER = new AtomicInteger();
    }
}
